package struct_valid

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"time"
)

type Person struct {
	Age      int       `form:"age" binding:"required,gt=10"`
	Name     string    `form:"name" binding:"required"`
	Birthday time.Time `form:"birthday" time_format:"2006-01-02" time_utc:"1"`
}

func init() {
	r := gin.Default()
	r.GET("/51mh", func(context *gin.Context) {
		var person Person
		if err := context.ShouldBind(&person); err != nil {
			context.String(500, fmt.Sprint(err))
			return
		}
		fmt.Println(person.Birthday)
		context.String(200, fmt.Sprintf("%#v", person))
	})
	r.Run(":8080")
}
